# 定义两个变量
static-lib = libmymath.a
dynamic-lib = libfunc.so

# 定义伪目标，依赖的是上面两个变量所保存的动静态库文件
.PHONY: all
all: $(static-lib) $(dynamic-lib)
# 构建静态库
$(static-lib): mymath.o
	ar -rc $@ $^
mymath.o: mymath.c
	gcc -c $^
# 构建动态库
$(dynamic-lib): mylog.o
	gcc -shared $^ -o $@
mylog.o: mylog.c
	gcc -fPIC -c $^

.PHONY: clean
clean:
	rm -rf *.a *.o *so mylib
# 发布
.PHONY: output
output: 
	mkdir -p mylib/include
	mkdir -p mylib/lib
	cp *.h mylib/include
	cp *.a mylib/lib
	cp *.so mylib/lib
